package com.runvp.common.enums;


/**
 * 端口工作状态(idle:空闲,use:使用中,breakdown:故障)
 * @author xukk_dp
 */

public enum CargoUseStatus implements BaseEnumInterface {

    IDLE("idle", "空闲","Y"),
    BREAKDOWN("breakdown", "故障","N"),
    USE("use", "使用中","N");

    private final String code;
    private final String desc;
    private String defaulted;

    @Override
    public String getDefaulted() {
        return defaulted;
    }


    CargoUseStatus(String code, String desc, String defaulted) {
        this.code = code;
        this.desc = desc;
        this.defaulted = defaulted;
    }



    CargoUseStatus(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }


    @Override
    public String getCode() {
        return code;
    }
    @Override
    public String getDesc() {
        return desc;
    }


    /**
     * 根据code获取desc
     * @param code
     * @return str
     */
    public static String getDescByCode(String code){
        if(null == code || "".equals(code)){return  "" ;}
        for (CargoUseStatus e: CargoUseStatus.values()){
            if(code.equals(e.getCode())){
                return e.getDesc();
            }
        }
        return "";
    }
}
